import "./index.css";
import React, { useContext, useState } from "react";
import { TestContext } from "@/utils/symbol";
import MyTestOne from "../MyTestOne";
import { Button } from 'antd';

const MyTestTwo: React.FC = () => {
  const [myCount, setMyCount] = useState(0);

  //点击改变context的值
  const handleClick = () => {
    setMyCount(myCount + 1);
  };

  //清空context的值
  const handleClear = ()=>{
    setMyCount(0);
  }

  return (
    <>
      <div>
        这是我都测试context上下文的第二给组件---{myCount}
        ----使用usecontext传递过来的值
      </div>
      <Button onClick={handleClick}>点击我改变上下文的值</Button>
      <TestContext.Provider value={{ myCount, handleClick , handleClear }}>
        <MyTestOne />
      </TestContext.Provider>
    </>
  );
};

export default MyTestTwo;
